package com.chongyuan.consumer.mq.listener;

import org.springframework.beans.factory.annotation.Autowired;

import com.aliyun.openservices.ons.api.Action;
import com.aliyun.openservices.ons.api.ConsumeContext;
import com.aliyun.openservices.ons.api.Message;
import com.aliyun.openservices.ons.api.MessageListener;
import com.chongyuan.consumer.server.DeviceGpsMsgService;

public class GpsMessageListener<T> implements MessageListener {

	@Autowired
	private DeviceGpsMsgService deviceGpsMsgService;

	@Override
	public Action consume(Message message, ConsumeContext context) {
		// 处理上报的gps信息
		try {
			String gpsMsg = new String(message.getBody());
			deviceGpsMsgService.handleGpsMsg(gpsMsg);
			System.out.println(gpsMsg);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Action.CommitMessage;
	}

}
